
package com.kanjian.music.activity;

import com.kanjian.music.R;
import com.kanjian.music.util.DialogUtil;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.Toast;
import android.widget.VideoView;

public class LiveActivity extends Activity {

    private VideoView mVideoView;

    private RelativeLayout mLayout_loading;

    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        setContentView(R.layout.activity_live);
        initView();
    }

    private void initView() {
        mLayout_loading = (RelativeLayout) findViewById(R.id.live_loading_layout);
        mVideoView = (VideoView) findViewById(R.id.live_video);
        mVideoView
                .setVideoPath("http://101.226.50.79/videoctfs.tc.qq.com/i0129a6473o.m701.mp4?vkey=E3AC0E9649C3B94C9D204399DDA263D194A6D894B129F3E52FA94FF21018CDA7061B06EC78B552C3C72B9FA3D731E1E3F1EE5CD1F837E0B4&br=29&platform=2&fmt=auto&level=0&sdtfrom=v5010&sha=3c83638e7fc61f6d6c50f50de06502b3a2e1bb48");
        mVideoView.setOnPreparedListener(new OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                mLayout_loading.setVisibility(View.GONE);
            }
        });
        mVideoView.setOnErrorListener(new OnErrorListener() {

            @Override
            public boolean onError(MediaPlayer mp, int what, int extra) {
                Toast.makeText(LiveActivity.this, "获取直播失败", Toast.LENGTH_LONG).show();
                finish();
                return false;
            }
        });
        mVideoView.start();
    }

}
